package com.dtsheep.rxjava.stduy.observable;

import rx.Observable;
import rx.Subscriber;

/**
 * OnErrorReturnDemo
 *
 * <p>
 *     onErrorReturn 操作符
 * </p>
 *
 * @author chuanbai
 * @date 2024/5/18
 */
public class OnErrorReturnDemo {


    public void onErrorReturn01(){

        Observable<Integer> observable = Observable.unsafeCreate((Subscriber<? super Integer> num) -> {
            num.onNext(10 / 0);
            num.onCompleted();
        }).onErrorReturn(e -> 500);

        observable.subscribe(
                obj -> System.out.println(obj));

    }

    public static void main(String[] args) {
        OnErrorReturnDemo onErrorReturnDemo = new OnErrorReturnDemo();
        onErrorReturnDemo.onErrorReturn01();
    }
}
